<script type="text/javascript">
    $(document).ready(function(){
        jQuery(function() {
            var options1 = { 
                type:"POST",
                dataType : "text",
                buttons:$('#mainForm').find("button[name='button']"),
                async : true,
                cache: false,
                success:function(responseText, statusText)
                {
                    //alert(responseText);
                    var json = jQuery.parseJSON(responseText);
                    dialogMessage(json.messages);

                    return true;
                },
            };
            var v = jQuery("#mainForm").validate({
                debug: true,
                messages: {
                },
                rules: {
                },
                errorPlacement: function(error, element) {
                    var elementName = element.attr("name");
                    var idTip = elementName + 'Tip';
                    $("#" + idTip).html(error);
                },
                success: function(label) {
                    label.addClass("valid").text("Ok!")
                },
                submitHandler: function(form) {
                    jQuery(form).ajaxSubmit(options1);
                }
            });
        });
    });
</script>

<?php echo $this->form;?>